<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/css/style-app.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>预警提示</title>
<style>
.content_table {
	border: 1px solid #8DB2E3
}

.content_table td {
	height: 24px;
	padding: 5px
}

.content_table {
	width: 100%;
	border-collapse: collapse
}

.grid th {
	background: #E7F3FE;
	height: 27px;
	line-height: 27px;
	border: 1px solid #8DB2E3;
	padding-left: 5px
}

.content_table td {
	border: 1px solid #8DB2E3;
	padding-left: 5px
}
.col-md-3{float:left;width:33.33%;}
</style>
</head>

<body>
	<div class="top-part">
		<div class="header">
			<div class="return">
				<a href="javascript:history.go(-1);"></a>
			</div>
			<div class="header-title">现场安全预警详情</div>
		</div>
	</div>
	<div class="new-form" style="width: 100%; margin: 0 auto;">
		<div>
			<form id="proFm" method="post">
				<div class="content_container">
					<table class="content_table" id="display_table">
					</table>
					<div class="clear" id="attrs" style="width: 100%;margin:10px 0;"></div>
				</div>
			</form>
			<div style="text-align: center;" id="div1">
				<a href="#" class="d-btn btn-blue" onclick="savePro()">已处理</a>
			</div>
		</div>
	</div>
</body>
<script th:inline="javascript">
	var inspectiondate = [[${inspectiondate}]];
	var currentPro = {};
	
	$(document).ready(function() {
		$.ajax({
			type : 'GET',
			url :  "../selectTosafeInfo.do?inspectiondate="+inspectiondate,
			cache : false,
			processData : false,
			contentType : false,
			success : function(data) {
				$.each(data,function(i,val){
					if(val.item.type==0){
						$("#display_table").find("."+val.item.id).next().textbox('setValue',val.content=="true"?"已检查":"未检查");
					}
					if(val.item.type==1){
						$("#display_table").find("."+val.item.id).next().textbox('setValue',val.content);
					}
				});
				var atts = data[0].attachments;
				var tb="";
				$.each(atts,function(i,val){
					tb+= '<div class="col-md-3" ><img onclick="window.open(\'../'+val.url+'\',\'_blank\', \' toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no\');" style="width:150px;height:100px;" src="../'+val.url+'" alt="查看全图">';
					tb+= '</div>';
				});
				$('#attrs').empty().html(tb);
			},
			dataType : "json"
		});
		
		$.ajax({
			type : 'GET',
			url : "../inspectionitem",
			data : {status:2},
			contentType : "application/json",
			success : function(data) {
				items = data.rows;
				var html="";
				var _html="";
				$.each(items,function(i,val){
					if(val.type==0){
						html+='<tr><td style="width:95%;">'+val.content+'</td><td class="safe"><input type="hidden" class="itemid" value="'+val.id+'" /><input type="hidden" class="type" value="check" /><input class="easyui-checkbox content"/></td></tr>';
					}
					if(val.type==1){
						html+='<tr><td colspan=2 style="border-width: 0px 0px 0px 0px;" >'+val.content+'</td></tr><tr><td colspan=2 class="safe"  style="border-width: 0px 0px 1px 0px;"><input type="hidden" class="itemid" value="'+val.id+'" /><input type="hidden" class="type" value="text" /><input class="easyui-textbox content" data-options="multiline:true,required:true" style="width: 100%;height:50px;"/></td></tr>';
					}
					
					if(val.type==0){
						_html+='<tr><td style="width:95%;">'+val.content+'</td><td class="safe"><input type="hidden" class="'+val.id+'" /><input class="easyui-textbox content" data-options="readonly:true"/></td></tr>';
					}
					if(val.type==1){
						_html+='<tr><td colspan=2 style="border-width: 0px 0px 0px 0px;">'+val.content+'</td></tr><tr><td colspan=2 class="safe" style="border-width: 0px 0px 1px 0px;"><input type="hidden" class="'+val.id+'" /><input class="easyui-textbox content" data-options="multiline:true,readonly:true" style="width: 100%;height:50px;"/></td></tr>';
					}
				});
				html+='</tr><td colspan=2 style="text-align:center;">上传图片：<input class="easyui-filebox" data-options="prompt:\'添加图片\',buttonText:\'选择图片\',multiple:true,accept:\'image/*\'" id="images" name="images" style="width: 300px;"/></td></tr>';
				html+='</tr><td style="width:95%;">是否推送至预警</td><td><input type="checkbox" name="tosafe" id="tosafe" style="height:20px;"/></td></tr>';
				$('#content_table').append(html);
				$('#display_table').append(_html);
				$.parser.parse('#content_table');
				$.parser.parse('#display_table');
			},
			dataType : "json"
		});
	});

	function savePro() {
		currentPro.inspectiondate=inspectiondate;
		$.ajax({
			type : 'POST',
			url : "../safetyinspectionUpdate.do",
			data : JSON.stringify(currentPro),
			contentType : "application/json",
			success : function(data) {
				if (data.success){
					$.messager.alert('保存', '保存成功', 'success');
				}else{
					$.messager.alert('保存', '保存失败', 'error');
				}
				window.setInterval("window.location.href=document.referrer", 2000);
			},
			dataType : "json"
		});
	}
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(),month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(),hour = date.getHours(),min = date.getMinutes(),sec = date.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
</script>

</html>